package cn.com.joycode.nimble.core.message;

import cn.com.joycode.nimble.core.utils.ObjectMapperUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @author Max Woods
 */

@Slf4j
public class NbMsgMsgBody extends NbMsgHashMap {

    public NbMsgMsgBody() {
        super();
    }

    public NbMsgMsgBody(String value) {
        this();
        log.info("value:{}", value);
        try {
            TypeReference<Map<String, String>> typeReference = new TypeReference<Map<String, String>>() {
            };
            Map<String, String> map = ObjectMapperUtil.parseObject(value, typeReference);
            if (ObjectUtil.isNotNull(map)) {
                this.putAll(map);
            }
        } catch (Exception e) {
            log.error("对象转换异常", e);
        }
    }

}